package com.code.design.model.demo.decorator;

import com.code.design.model.demo.decorator.component.Car;
import com.code.design.model.demo.decorator.concretecomponent.BenzCar;
import com.code.design.model.demo.decorator.concretecomponent.BmwCar;
import com.code.design.model.demo.decorator.concretecomponent.TeslaCar;
import com.code.design.model.demo.decorator.concretedecorator.AutoCarDecorator;
import com.code.design.model.demo.decorator.concretedecorator.FlyCarDecorator;
import com.code.design.model.demo.decorator.decorator.CarDecorator;

/**
 * 客户端类负责创建被包装对象和装饰者，并决定如何进行包装和执行
 *
 * @author tangyifei
 */
public class Client {
    public static void main(String[] args) {
        Car benzCar = new BenzCar();
        Car bmwCar = new BmwCar();
        Car teslaCar = new TeslaCar();
        //创建自动驾驶的奔驰汽车
        CarDecorator autoBenzCar = new AutoCarDecorator(benzCar);
        //创建飞行的、自动驾驶的宝马汽车
        CarDecorator flyAutoBmwCar = new FlyCarDecorator(new AutoCarDecorator(bmwCar));

        benzCar.run();
        bmwCar.run();
        teslaCar.run();
        autoBenzCar.run();
        flyAutoBmwCar.run();
    }
}
